﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.IO;

namespace Directory.Web
{
    public partial class Admin_CategoryExport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int categoryId;
            if (!int.TryParse(Request.QueryString["categoryid"], out categoryId))
            {
                categoryId = WebSettings.GetInstance().RootCategoryId;
            }
            Response.Clear();
            Response.HeaderEncoding = Encoding.GetEncoding("gb2312");
            Response.ContentType = "application/vnd.ms-excel";
            Response.ContentEncoding = Encoding.UTF8;
            GridView gv = new GridView();
            gv.DataSource = CategoryDataProxy.GetExportDataSet(categoryId);
            gv.DataBind();
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gv.RenderControl(htw);
            Response.Write(sw);
            Response.End();
        }
    }
}